<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <link rel="stylesheet" href="../../libs/mui.min.css"/>
    <link rel="stylesheet" href="../../libs/app.css"/>
    <link rel="stylesheet" href="../../css/mui.listpicker.css"/>
    <link rel="stylesheet" href="../../css/mui.poppicker.css"/>
    <link rel="stylesheet" href="../../css/main.css"/>
    <link rel="stylesheet" href="../../css/askfor.css"/>
</head>

<body>
<div class="head">
    <img class="mui-action-back" src="../../images/all-left.png" alt="">
    <p>申请信息</p>
</div>
<div class="context2">
    <div class="state">
        <div><span class="one">1</span>
            <p>申请人信息</p>
        </div>
        <div>
        </div>
        <div><span class="three">2</span>
            <p>申请结果</p>
        </div>
        <img class="gang3" src="../../images/white-gang.png" alt="">
    </div>
    <div class="message">
        <div>
            <p>银行</p>
            <input class="bank" type="text" placeholder="单行输入">
        </div>
        <div>
            <p>中文名</p>
            <input class="name" type="text" placeholder="单行输入">
        </div>
        <div>
            <p>姓名拼音</p>
            <input class="pinying" type="text" placeholder="单行输入">
        </div>
        <div>
            <p>身份证号</p>
            <input class="card" type="text" placeholder="单行输入">
        </div>
        <div>
            <p>手机号码</p>
            <input class="phone" type="text" placeholder="单行输入">
        </div>
        <div id='showCityPicker3' class="mui-btn mui-btn-block">
            <p>申请地点</p>
            <i class="icon-editCity"></i>
            <input readonly="true" id='cityResult3' class="ui-alert area" placeholder="请选择" type="text"/>
        </div>
    </div>

    <div class="button">
        <button id="askfor3">下一步</button>
    </div>
</div>

<script src="../../js/jquery-3.1.1.min.js"></script>
<script src="../../libs/mui.min.js"></script>
<script src="../../js/url.js"></script>
<script src="../../js/city-data-3.js"></script>
<script src="../../js/mui.listpicker.js"></script>
<script src="../../js/mui.poppicker.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=AIEts6CoFGpdivbIz3uI3SrAG9iDB0Ko"></script>
<script src="../../js/location.js"></script>
<script src="../../js/city-public.js"></script>
<script>
    $(function () {
        var bank = localStorage.getItem('signCard-askforCardNative');
        localStorage.removeItem('signCard-askforCardNative');
        var token = localStorage.token;
        $('.bank').val(bank);
        //接口
        $('#askfor3').on('tap', function () {
            //				var bank ='raf';
            var card = $('.card').val();
            var name = $('.name').val();
            var pinying = $('.pinying').val();
            var phone = $('.phone').val();
            var area = $('.area').val();
            var hanzi = /^[\u4e00-\u9fa5]{0,}$/;
            var sfzh = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
            var py = /^[A-Za-z]+$/;
            var hm = /^1[34578]\d{9}$/;

            if ((!hanzi.test(name)) || name == '') {
                mui.toast('请输检查您中文名');
                return;
            } else if ((!py.test(pinying)) || pinying == '') {
                mui.toast('请输检查您姓名拼音');
                return;
            } else if ((!sfzh.test(card)) || card == '') {
                mui.toast('请输检查您身份证号');
                return;
            } else if ((!hm.test(phone)) || phone == '') {
                mui.toast('请输检查您电话号码');
                return;
            } else if (area == '') {
                mui.toast('请检查您输入的信息');
                return;
            } else {
                if (localStorage.dk_type == 2) {
                    b();
                } else {
                    a();
                }
            }

            function a() {
                $.ajax({
                    url: ur + 'rest/loanController/request',
                    type: "post",
                    dataType: "json",
                    headers: {
                        "X-Token": token
                    },
                    data: {
                        loanCode: 'card-native',
                        evaluateId: localStorage.evaluateId,
                        point: (localStorage.locationPoint ? localStorage.locationPoint : ''), // 坐标
                        params: '{"bank":"' + bank + '","id_card":"' + card + '","name":"' + name + '","pinying":"' + pinying + '","phone":"' + phone + '","area":"' + area + '"}'
                    },
                    success: function (data) {
                        if (data.meta.code == 'S002') {
                            href('askfor3-aj.html', 'askfor3-aj');
                        }
                    }
                })
            }

            // 快速贷款
            function b() {
                $.ajax({
                    url: ur + 'rest/quickLoanController/quick-request',
                    type: "post",
                    dataType: "json",
                    headers: {
                        "X-Token": token
                    },
                    data: {
                        loanCode: 'card-native',
                        partnerId: localStorage.fast_partner,
                        quickId: localStorage.fast_id,
                        evaluateId: localStorage.evaluateId,
                        params: '{"bank":"' + bank + '","id_card":"' + card + '","name":"' + name + '","pinying":"' + pinying + '","phone":"' + phone + '","area":"' + area + '"}'
                    },
                    success: function (data) {
                        if (data.meta.code == 'S002') {
                            href('askfor3-aj.html', 'askfor3-aj');
                        }
                    }
                })
            }
        });
    });
</script>
</body>

</html>